import java.util.TreeSet;

public class Demo4 {
    public static void main(String[] args) {
        int[] nums = {1,1,2};
        removeDuplicates(nums);
    }
    public static int removeDuplicates(int[] nums) {
        int[] tmp = new int[nums.length];
        int k = 0;
        TreeSet<Integer> set = new TreeSet<>();
        for(int i = 0; i<nums.length;i++) {
            if(!set.contains(nums[i])){
                tmp[k++] = nums[i];
                set.add(nums[i]);
            }
        }
        return k;
    }
}
